home *** CD-ROM | disk | FTP | other *** search
- Path: kuhub.cc.ukans.edu!anh
- From: anh@kuhub.cc.ukans.edu
- Newsgroups: comp.lang.c
- Subject: Re: Schildt <- Advanced Books
- Message-ID: <1996Mar7.162150.115560@kuhub.cc.ukans.edu>
- Date: 7 Mar 96 16:21:50 CST
- References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <danpop.826121528@rscernix>
- Organization: University of Kansas Academic Computing Services
-
- Er, so what do you use instead of %d ?
-
- Anh
-
- In article <danpop.826121528@rscernix>, danpop@mail.cern.ch (Dan Pop) writes:
- > In <4he6hb$ahn@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes:
- >
- >>In article <danpop.825687663@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
- >>>Sorry, I can hardly believe that. Here are two examples (originally
- >>>posted by Lawrence Kirby) from page 53 of the _third_ edition of C-TCR:
- >>
- >>> float f
- >>> printf("%f ", sizeof f);
- >>> printf("%d", sizeof(int));
- >>>
- >>>Both mistakes appeared in the second edition of the book, as well, and
- >>>they are NOT typos. Ideally, the author shouldn't be allowed to
- >>>publish anything on a topic he is utterly unable to understand.
- >>>Unfortunately, the market realities of today are far from ideal :-(
- >>
- >>I could consider the "%f" a typo; it is when I do it.
- >
- > "%f" might be a typo (yet it was preserved between editions, so maybe
- > it was not a typo :-) but the missing cast _cannot_ be a typo.
- >
- >>The others are
- >>stunning; the size_t vs int bug is subtle.
- >
- > There is nothing subtle here, for someone who knows C (which rules Schildt
- > out :-) size_t is _guaranteed_ not to be defined as int, so using "%d"
- > is plain idiotic. I could understand a "%u", and qualify the author as
- > mildly stupid :-)
- >
- >
- >>The sizeof(ptr) bug is idiotic.
- >
- > Every single bit as idiotic as "%d" for size_t. Under special
- > circumstances, both give the "correct" results. At least, sizeof(ptr)
- > doesn't invoke undefined behaviour :-)
- >
- > Dan
- > --
- > Dan Pop
- > CERN, CN Division
- > Email: danpop@mail.cern.ch
- > Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-